﻿@page "/xlsio/autoshapes"
@inject Microsoft.JSInterop.IJSRuntime JS
@using System.IO;

@using Syncfusion.Blazor.Buttons
@*Hidden:Lines*@

@using BlazorDemos.Data.FileFormats.XlsIO

@*End:Hidden*@
@inherits SampleBaseComponent;

<SampleDescription>
    <p>This sample demonstrates how to use AutoShapes in spreadsheets using XlsIO.</p>
</SampleDescription>
<ActionDescription>
   <p>AutoShapes help you to draw objects on your document. You can create various shapes using AutoShapeType enumeration. Once you insert an AutoShape, you can also put a text inside it and you can move or resize them as you wish.</p>
<p style='display: block'>The <b>IShape</b> interface is the in-memory representation of the AutoShapes in an Excel workbook. These are used to create Autoshapes and to set properties for those shapes. The <b>ITextFrame</b> interface can be used to set various shape text formats.</p>
<p style='display: block'><b>Features:</b></p>
<p style='display: block'>Essential XlsIO supports all major AutoShape features. This sample demonstrates the following features:</p>
<ul>
<li>Shape Text</li>
<li>Text Alignment</li>
<li>SolidFill</li>
</ul>
</ActionDescription>

<div class="control-section">
    <p style="font-weight:normal">Click the button to view an Excel spreadsheet generated by Essential XlsIO. Please note that Microsoft Excel Viewer or Microsoft Excel is required to view the resultant document.</p>

    <div class="button-section">
        <div id="button-control">
            <div class="row">
                <div>
                    <SfButton @onclick="AutoShapesXlsIO">Create Document</SfButton>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .control-section .row {
        margin: 10px 0;
    }
</style>

@code {
    MemoryStream excelStream;

    /// <summary>
    /// Create and download the Excel document with auto shapes
    /// </summary>
    public async Task AutoShapesXlsIO()
    {
        AutoShapesService service = new AutoShapesService();
        excelStream = service.AutoShapesXlsIO();
        await JS.SaveAs("Sample.xlsx", excelStream.ToArray());
    }
}